public class ChristmasTree {
    public static void main(String[] args) {
        int treeHeight = 10;
        drawTree(treeHeight);
        drawTrunk(treeHeight);
    }

    public static void drawTree(int height) {
        for (int i = 1; i <= height; i++) {
            // 打印空格
            for (int j = 0; j < height - i; j++) {
                System.out.print(" ");
            }
            // 打印星号
            for (int k = 0; k < 2 * i - 1; k++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    public static void drawTrunk(int height) {
        int baseWidth = 3;
        int trunkWidth = baseWidth;
        int trunkHeight = 2;
        int spaceBeforeTrunk = height - 1;
        for (int i = 0; i < trunkHeight; i++) {
            // 打印空格
            for (int j = 0; j < spaceBeforeTrunk; j++) {
                System.out.print(" ");
            }
            // 打印树干
            for (int k = 0; k < trunkWidth; k++) {
                System.out.print("|");
            }
            System.out.println();
        }
    }
}
